import {request} from '@/utils/request'
import {PermissionRes, AddPermission, EditPermission} from '@/types/permission'

// 获取权限列表
export const getPermissionListApi = () => {
  return request<PermissionRes[]>('/sys/permission')
}

// 获取权限详情
export const getPermissionDetailApi = (id: string) => {
  return request<EditPermission>(`/sys/permission/${id}`)
}

// 新增权限
export const addPermissionApi = (data: AddPermission) => {
  return request('/sys/permission', 'POST', data)
}

// 修改权限
export const updatePermissionApi = (data: EditPermission) => {
  return request(`/sys/permission/${data._id}`, 'PUT', data)
}

// 删除权限
export const deletePermissionApi = (id: string) => {
  return request(`/sys/permission/${id}`, 'DELETE')
}